//
//  YQRootViewController.m
//  iyuanqi
//
//  Created by czl on 2017/7/27.
//  Copyright © 2017年 czl. All rights reserved.
//

#import "YQRootViewController.h"
#import "YQForumViewController.h"
#import "YQMessageViewController.h"
#import "YQMeViewController.h"

@interface YQRootViewController ()

@end

@implementation YQRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
    [[UINavigationBar appearance] setBarTintColor:MainColor];
    [[UINavigationBar appearance] setTranslucent:NO];
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    //设置导航栏后退按钮颜色
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    //去掉导航栏后退按钮的文字
    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:0.001],NSForegroundColorAttributeName:[UIColor clearColor]} forState:UIControlStateNormal];
    
    YQForumViewController* forumVC = [[YQForumViewController alloc]init];
    UINavigationController* nav1 = [[UINavigationController alloc]initWithRootViewController:forumVC];
    
    YQMessageViewController* messageVC = [[YQMessageViewController alloc]init];
    UINavigationController* nav2 = [[UINavigationController alloc]initWithRootViewController:messageVC];
    
    YQMeViewController* meVC = [[YQMeViewController alloc]init];
    UINavigationController* nav3 = [[UINavigationController alloc]initWithRootViewController:meVC];
    
    self.viewControllers = @[nav1,nav2,nav3];
    self.tabBar.barTintColor = [UIColor whiteColor];
    self.tabBar.backgroundColor = [UIColor whiteColor];
    
    forumVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"论坛" image:[[UIImage imageNamed:@"tab_forum"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab_forum_hl"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self setTabBarItemsTitlesColor:forumVC.tabBarItem];
    messageVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"消息" image:[[UIImage imageNamed:@"tab_message"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab_message_hl"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self setTabBarItemsTitlesColor:messageVC.tabBarItem];
    meVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:[[UIImage imageNamed:@"tab_me"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab_me_hl"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self setTabBarItemsTitlesColor:meVC.tabBarItem];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setTabBarItemsTitlesColor:(UITabBarItem *)item {
    [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                  [UIColor blackColor], NSForegroundColorAttributeName,[UIFont systemFontOfSize:12.0],NSFontAttributeName,
                                  nil] forState:UIControlStateNormal];
    [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                  MainColor, NSForegroundColorAttributeName,[UIFont systemFontOfSize:12.0],NSFontAttributeName,
                                  nil] forState:UIControlStateSelected];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}

@end
